package com.haoan.index.service.impl;


import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.haoan.index.common.enums.ValiFlag;

import com.haoan.index.mapper.LcLeaveWordMapper;
import com.haoan.index.domain.LcLeaveWord;
import com.haoan.index.service.LcLeaveWordService;

/**
 * 留言Service业务层处理
 * 
 * @author autoGen
 * @date 2025-03-20
 */
@Service
public class LcLeaveWordServiceImpl extends ServiceImpl<LcLeaveWordMapper,LcLeaveWord> implements LcLeaveWordService
{
    /**
     * 查询留言
     * 
     * @param id 留言主键
     * @return 留言
     */
    @Override
    public LcLeaveWord selectLcLeaveWordById(Long id)
    {
        return baseMapper.selectById(id);
    }

    /**
     * 查询留言列表
     * 
     * @param lcLeaveWord 留言
     * @return 留言
     */
    @Override
    public List<LcLeaveWord> selectLcLeaveWordList(LcLeaveWord lcLeaveWord)
    {
        LambdaQueryWrapper<LcLeaveWord> queryWrapper = new LambdaQueryWrapper<>();
        //todo 添加查询条件
        queryWrapper.eq(lcLeaveWord.getId() != null, LcLeaveWord::getId, lcLeaveWord.getId());
        queryWrapper.eq(lcLeaveWord.getName() != null, LcLeaveWord::getName, lcLeaveWord.getName());
        queryWrapper.eq(lcLeaveWord.getCompany() != null, LcLeaveWord::getCompany, lcLeaveWord.getCompany());
        queryWrapper.eq(lcLeaveWord.getPhone() != null, LcLeaveWord::getPhone, lcLeaveWord.getPhone());
        queryWrapper.eq(lcLeaveWord.getDemand() != null, LcLeaveWord::getDemand, lcLeaveWord.getDemand());
        queryWrapper.eq(lcLeaveWord.getTime() != null, LcLeaveWord::getTime, lcLeaveWord.getTime());
        return baseMapper.selectList(queryWrapper);
    }

    /**
     * 新增留言
     * 
     * @param lcLeaveWord 留言
     * @return 结果
     */
    @Transactional
    @Override
    public int insertLcLeaveWord(LcLeaveWord lcLeaveWord)
    {
        return baseMapper.insert(lcLeaveWord);
    }

    /**
     * 修改留言
     * 
     * @param lcLeaveWord 留言
     * @return 结果
     */
    @Transactional
    @Override
    public int updateLcLeaveWord(LcLeaveWord lcLeaveWord)
    {
        return baseMapper.updateById(lcLeaveWord);
    }

    /**
     * 批量删除留言
     * 
     * @param ids 需要删除的留言主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteLcLeaveWordByIds(Long [] ids)
    {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除留言信息
     * 
     * @param id 留言主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteById(Long id)
    {
        return baseMapper.deleteById(id);
    }
}
